#include <iostream>
#define IS_BASE
#include "include.h"



int main()
{


    obj_manager *objs=new obj_manager;

    object *loaded=parse_obj("square.obj", ".png");//spring4.obj");
    ///must be trianglated and have normals exported



    std::cout << loaded->texname;

    loaded->texture_load();

    objs->add_obj(loaded);

    Engine engine;


    oclstuff();
    engine.init_glcl();


    engine.load(1000, 700, 700, false); ///dimensions - x, y, z, FULLSCREEN
    ///performance quickly degrades with screen size due to the screen filling operation
    ///nope, opengl


    //sf::Keyboard keyboard;
    //sf::Mouse mouse;

    engine.c_pos.z=-24; ///starting camera position. Completely arbitrary, but designed to give a reasonably full shot of object as a reliable performance benchmark

    int mult=100;
    ///position of light, colour of light. Yes, this needs to be much improved, but currently a useful stopgap measure
    cl_float4 l1, c1;
    l1.x=-20, l1.y=0, l1.z=5, l1.w=50;
    c1.x=0, c1.y=0, c1.z=255;


    cl_float4 l2, c2;
    l2.x=-0, l2.y=0, l2.z=-0, l2.w=90;
    c2.x=250, c2.y=0, c2.z=0;

    engine.add_light(l1, c1);
    //for(int i=0; i<100; i++)
    engine.add_light(l2, c2);

    cl_float4 l3= {10, 0, 20, 40},
              c3= {0, 255, 0};

    cl_float4 l4= {-10, 0, 20, 20},
              c4= {255, 255, 0};



    engine.add_light(l3, c3);
    engine.add_light(l4, c4);



    cl_float4 l5= {3, -20, 10, 25},
              c5= {0, 255, 255};

    cl_float4 l6= {-3, -20, -10, 25},
              c6= {128, 128, 128};


    engine.add_light(l5, c5);
    //for(int i=0; i<50; i++)
    engine.add_light(l6, c6);




    //cl_float4 l7={-3, -200, -10, 800},
    // c7={128, 128, 128};
    //engine.add_light(l7, c7);
    //engine.add_light(l7, c7);



    boost::thread thread(boost::bind(&obj_manager::push_objects, objs)); ///have this fired by obj->push

    //objs->push_objects();


    //thread.join();

    ///texture is causing shit to crash handle in memory manager al,so store the number of triangles for every object being passed so we know which texture goes where, OR pass super texture and adjust coordinates based on actual size on texture, though opencl might not like that so IONO
    engine.set_ambiance(255.0f, 255.0f, 255.0f, 0.3f); // change this to ambient colour
    while(engine.window.IsOpened())
    {



        engine.tick();

    }


    clReleaseKernel(cl::kernel);
    clReleaseProgram(cl::program);
    clReleaseCommandQueue(cl::cqueue);
    clReleaseContext(cl::context);



    return 0;
}
